package com.kh.rationaldrugreview.neo4j.entity;

import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.Relationship;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.util.Set;

/**
 * 患者特征相关的Neo4j实体定义
 * Patient profile related Neo4j entities
 */
public class PatientProfileEntities {
    
    /**
     * 患者画像实体
     * Patient Profile Entity
     */
    @Node("PATIENT_PROFILE")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class PatientProfileNode {
        @Id @GeneratedValue
        private Long id;
        
        @Property("profileId")
        private String profileId;
        
        @Property("ageGroup")
        private String ageGroup; // 新生儿/婴幼儿/儿童/青少年/成人/老年人
        
        @Property("ageRangeMin")
        private Integer ageRangeMin;
        
        @Property("ageRangeMax")
        private Integer ageRangeMax;
        
        @Property("gender")
        private String gender; // 男/女/不限
        
        @Property("pregnancyStatus")
        private String pregnancyStatus; // 未怀孕/孕早期/孕中期/孕晚期/不适用
        
        @Property("lactationStatus")
        private String lactationStatus; // 哺乳期/非哺乳期/不适用
        
        @Property("specialConditions")
        private String specialConditions; // JSON格式的特殊状况列表
        
        @Property("renalFunction")
        private String renalFunction; // 正常/轻度不全/中度不全/重度不全/透析
        
        @Property("hepaticFunction")
        private String hepaticFunction; // 正常/轻度不全/中度不全/重度不全
        
        @Property("description")
        private String description;
        
        @Relationship(type = "SUITABLE_FOR_DRUGS", direction = Relationship.Direction.INCOMING)
        private Set<DrugNode> suitableDrugs;
        
        @Relationship(type = "CONTRAINDICATED_DRUGS", direction = Relationship.Direction.INCOMING)
        private Set<DrugNode> contraindicatedDrugs;
    }
    
    /**
     * 妊娠分级实体
     * Pregnancy Category Entity (FDA Classification)
     */
    @Node("PREGNANCY_CATEGORY")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class PregnancyCategoryNode {
        @Id @GeneratedValue
        private Long id;
        
        @Property("category")
        private String category; // A, B, C, D, X
        
        @Property("name")
        private String name;
        
        @Property("description")
        private String description;
        
        @Property("riskLevel")
        private String riskLevel; // 安全/相对安全/权衡利弊/有风险/禁用
        
        @Property("chineseDescription")
        private String chineseDescription;
        
        @Relationship(type = "DRUGS_IN_CATEGORY", direction = Relationship.Direction.INCOMING)
        private Set<DrugNode> drugsInCategory;
    }
    
    /**
     * 年龄组实体
     * Age Group Entity
     */
    @Node("AGE_GROUP")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class AgeGroupNode {
        @Id @GeneratedValue
        private Long id;
        
        @Property("groupName")
        private String groupName;
        
        @Property("ageRangeMin")
        private Integer ageRangeMin; // 最小年龄（月）
        
        @Property("ageRangeMax")
        private Integer ageRangeMax; // 最大年龄（月）
        
        @Property("ageRangeMinYears")
        private Double ageRangeMinYears; // 最小年龄（年）
        
        @Property("ageRangeMaxYears")
        private Double ageRangeMaxYears; // 最大年龄（年）
        
        @Property("description")
        private String description;
        
        @Property("specialConsiderations")
        private String specialConsiderations; // 特殊考虑事项
    }
    
    /**
     * 特殊生理状态实体
     * Special Physiological State Entity
     */
    @Node("PHYSIOLOGICAL_STATE")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class PhysiologicalStateNode {
        @Id @GeneratedValue
        private Long id;
        
        @Property("stateName")
        private String stateName; // 月经期/更年期/青春期等
        
        @Property("gender")
        private String gender; // 适用性别
        
        @Property("ageRange")
        private String ageRange; // 适用年龄范围
        
        @Property("description")
        private String description;
        
        @Property("hormonalChanges")
        private String hormonalChanges; // 激素变化
        
        @Property("drugMetabolismImpact")
        private String drugMetabolismImpact; // 对药物代谢的影响
    }
    
    /**
     * 器官功能状态实体
     * Organ Function Status Entity
     */
    @Node("ORGAN_FUNCTION")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class OrganFunctionNode {
        @Id @GeneratedValue
        private Long id;
        
        @Property("organName")
        private String organName; // 肝/肾/心脏等
        
        @Property("functionLevel")
        private String functionLevel; // 正常/轻度不全/中度不全/重度不全/衰竭
        
        @Property("clinicalMarkers")
        private String clinicalMarkers; // 临床指标（如肌酐清除率等）
        
        @Property("dosageAdjustmentFactor")
        private Double dosageAdjustmentFactor; // 剂量调整系数
        
        @Property("contraindicatedDrugs")
        private String contraindicatedDrugs; // 禁用药物列表（JSON）
        
        @Property("cautionDrugs")
        private String cautionDrugs; // 慎用药物列表（JSON）
    }
    
    /**
     * 遗传代谢类型实体
     * Genetic Metabolizer Type Entity
     */
    @Node("METABOLIZER_TYPE")
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class MetabolizerTypeNode {
        @Id @GeneratedValue
        private Long id;
        
        @Property("typeName")
        private String typeName; // 超快代谢型/快代谢型/正常代谢型/慢代谢型/超慢代谢型
        
        @Property("enzyme")
        private String enzyme; // 相关酶（如CYP2D6）
        
        @Property("frequency")
        private String frequency; // 人群频率
        
        @Property("ethnicVariation")
        private String ethnicVariation; // 种族差异
        
        @Property("clinicalImplication")
        private String clinicalImplication; // 临床意义
        
        @Property("dosageRecommendation")
        private String dosageRecommendation; // 剂量建议
    }
}